home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1993 / MacHack 1993.toast / MacHack™ 1987-1992 / MacHack™ '90 / Utilities ƒ / MPW Tools ƒ / Simula4.07 / Simula 4.07ƒ / SInterfaces / macWindowMgr.sim < prev    next >
Encoding:
Text File  |  1989-05-01  |  3.9 KB  |  126 lines  |  [TEXT/MPS ]

  1. % ---------------------------------------------------------------------------
  2. %    Class Mac WindowMgr
  3. % In this module you find the programmers interface to the Window
  4. % Manager.It is built on top of the TOOLBOX routines in TOOLBOXWindows.
  5. % The routines put here are those that are not naturally an attribute of
  6. % a window, rather manageing the windows. This class is only intended to
  7. % be instantiated once (and usually as the part of its subclass 
  8. % macProcessMGR)
  9. % When an object of this class is created, all other Toolbox Managers
  10. % are initialized. This should naturally only be done Once.
  11. %
  12. % For a description of the routines see Inside Macintosh.
  13. %
  14. % 890317/Boris Magnusson
  15. % This module contains an internal Simset list of notices to all
  16. % created Windows.
  17. % ---------------------------------------------------------------------------
  18. External class TOOLBOXWindow="::SInterfaces:ToolboxWindow";
  19. External class MACWindow="::SInterfaces:MacWindow";
  20. External class MACRect="::SInterfaces:MacRect";
  21. External class MacPoint="::SInterfaces:MacPoint";
  22. External class MacToolConst="::SInterfaces:MacToolConst";
  23. External class MacUtilities="::SInterfaces:MacUtilities";
  24.  
  25. Simset class MacWindowMgr;
  26. begin
  27.         
  28.     ref(MacUtilities) Util;    ! To access general utilities of Toolbox;
  29.     ref(MacToolConst) TConst;  ! To access CONST:s from Toolintf;
  30.     ref(TOOLBOXWindow) TOOLBOX;! To access Quickdraw & Window traps;
  31.     ref(macWindow) SelectedWindow;! The currently selected W. ;
  32. ! ----------------------------;    
  33.     integer NIL=0;
  34.     
  35.     procedure InitWindows; TOOLBOX.TOOLBOXInitWindows;
  36.  
  37.     procedure RegisterWindow(W); ref(macWindow) W;
  38.     begin
  39.         new WindowNotice(W);
  40.         SelectWindow(W); ! make new Window the selected one ;
  41.     end;
  42.         
  43.     procedure SelectWindow(W);ref(macWindow) W;
  44.     begin
  45.         TOOLBOX.TOOLBOXSelectWindow(W.WindowPtr);
  46.         W.Setport;
  47.         SelectedWindow:-W;
  48.     end --- Select Window --- ;
  49.  
  50.     procedure DisposeWindow(W); ref(MACWindow) W;
  51.     begin
  52.         TOOLBOX.TOOLBOXDisposeWindow(W.WindowPtr);
  53.         ConvertToNotice(W.WindowPtr).out;
  54.     end;
  55.  
  56.     ref(MACWindow) procedure FrontWindow;
  57.         FrontWindow:-ConvertToWindow(TOOLBOX.TOOLBOXFrontWindow);
  58.  
  59.     short integer procedure FindWindow(thePoint,WhichWindow);
  60.         name WhichWindow;
  61.         ref(MACPoint) thePoint;
  62.         ref(MacWindow) WhichWindow;
  63.     begin integer W;
  64.             FindWindow:=TOOLBOX.TOOLBOXFindWindow(thePoint.h,thePoint.v,W);
  65.             WhichWindow:-ConvertToWindow(W)
  66.     end;
  67.     
  68. % Special routine to reach the screen rectangle
  69.  
  70.     external Pascal procedure x="PascalGetScreenRect" is
  71.         procedure PascalGetScreenRect(theRect_top);
  72.             name theRect_top;
  73.             short integer theRect_top;;
  74.             
  75.     procedure GetScreenRect(aRect); ref(MACRect) aRect;
  76.     begin
  77.         PascalGetScreenRect(aRect.Top);
  78.     end;
  79.  
  80. % ---------------------------------------------------------
  81.  
  82. ! -------- Internal Routines --------------- ;
  83.  
  84.     ref(MACWindow) procedure ConvertToWindow(windowptr); integer windowptr;
  85.     begin
  86.         ! search all created windows for one with windowptr 
  87.         ! equal to the param;
  88.         ref(windowNotice) p;
  89.         p:-wq.first;
  90.         while p=/= none and then p.W.Windowptr<>Windowptr do
  91.             p:-p.suc;
  92.         if p=/=none then
  93.             ConvertToWindow:-p.W
  94.         else
  95.         begin ! else not our window ;
  96.             ghostWindow.Windowptr:=windowptr;
  97.             convertToWindow:-ghostWindow;
  98.         end;
  99.     end;
  100.  
  101.     ref(WindowNotice) procedure ConvertToNotice(windowptr); integer windowptr;
  102.     begin
  103.         ! search all created windows for one with windowptr 
  104.         ! equal to the param;
  105.         ref(windowNotice) p;
  106.         p:-wq.first;
  107.         while p=/= none and then p.W.Windowptr<>Windowptr do
  108.             p:-p.suc;
  109.         if p=/=none then
  110.             ConvertToNotice:-p; ! else not a window hit ;
  111.     end;
  112.  
  113.     link class WindowNotice(W); ref(MACWindow) W; into(WQ);
  114.  
  115. ! -- Initialization --- ;
  116.     ref(MacWindow) GhostWindow; ! used to reprsent windows 
  117.                                          ! in other Applications ;
  118.     ref(Head) WQ;
  119.     WQ:-new Head;
  120.     
  121.     Util:-new MacUtilities;    ! To access general utilities of Toolbox;
  122.     TConst:-new MacToolConst;  ! To access CONST:s from Toolintf;
  123.     TOOLBOX:-new TOOLBOXWindow;! To access Quickdraw & Window traps;;
  124.     GhostWindow:- new MacWindow;
  125. END --- MAC Window Manager --- ;